/*

dp[i][j]=源串前i个字符匹配目标串前j个字符所需要的最小操作次数

如果第i个字符==第j个字符
dp[i][j]=dp[i-1][j-1]
如果不相等
dp[i][j]=min{
    dp[i-1][j],
    dp[i][j-1],
    dp[i-1][j-1]
}+1

dp[i][j]=INT_MAX
dp[0][0]=0
dp[i][0]=i
dp[0][j]=j
*/
#include <algorithm>
#include <climits>
#include <cstdint>
#include <iostream>
#include <istream>
#include <string>
#include <vector>
using ll = int64_t;

int main(){
    std::iostream::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::string s1,s2;
    std::cin>>s1>>s2;
    ll n=s1.size(),m=s2.size();
    s1=' '+s1;
    s2=' '+s2;
    std::vector<std::vector<ll>> dp(s1.size(),std::vector<ll>(s2.size(),INT_MAX));
    for(ll i=0;i<dp.size();i++)dp[i][0]=i;
    for(ll j=0;j<dp[0].size();j++)dp[0][j]=j;
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=m;j++){
            if(s1[i]==s2[j]){
                dp[i][j]=dp[i-1][j-1];
            }else{
                dp[i][j]=std::min({
                    dp[i-1][j],
                    dp[i][j-1],
                    dp[i-1][j-1]
                })+1;
            }
        }
    }
    std::cout<<dp[n][m]<<"\n";
}